﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using Maticsoft.Model;
namespace Maticsoft.BLL
{
	/// <summary>
	/// studentInfo
	/// </summary>
	public partial class studentInfo
	{
		private readonly Maticsoft.DAL.studentInfo dal=new Maticsoft.DAL.studentInfo();
        private readonly Maticsoft.DAL.keyinfo dalk = new Maticsoft.DAL.keyinfo();
       
		public studentInfo()
		{}
        public bool UpdateKZ(int sid, string ids, int seat)
        {
            return dal.UpdateKZ(sid, ids, seat);
        }
        public bool Updatestate(int sid, string ids)
        {
            return dal.Updatestate(sid, ids);
        }
        public DataSet Getsturoomkz(string strWhere)
        {
            return dal.Getsturoomkz(strWhere);
        }
        public int GetInId(string numid)
        {
            return dal.GetInId(numid);
        }
        public DataSet Getsturoom(string strWhere)
        {
            return dal.Getsturoom(strWhere);
        }
        public DataSet GetPaperDetail(int id)
        {
            return dal.GetPaperDetail(id);
        }
        public DataSet GetPaperDetailbytype(string type)
        {
            return dal.GetPaperDetailbytype(type);
        }
        public string GetType(int id)
        {
            return dal.GetType(id);
        }
        public string GetTime(int id)
        {
            return dal.GetTime(id);
        }
        public bool Updates(int id)
        {
            return dal.Updates(id);
        }
        public bool UpdateTime(int id,string t)
        {
            return dal.UpdateTime(id,t);
        }
        /// <summary>
        /// 获得得分数据列表
        /// </summary>
        public DataSet GetListScoreDetail(string strWhere)
        {
            return dal.GetListScoreDetail(strWhere);
        }
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int stuId)
		{
			return dal.Exists(stuId);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(Maticsoft.Model.studentInfo model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Maticsoft.Model.studentInfo model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int stuId)
		{
			
			return dal.Delete(stuId);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string stuIdlist )
		{
            dalk.DeleteListstu(stuIdlist);
			return dal.DeleteList(stuIdlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Maticsoft.Model.studentInfo GetModel(int stuId)
		{
			
			return dal.GetModel(stuId);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public Maticsoft.Model.studentInfo GetModelByCache(int stuId)
		{
			
			string CacheKey = "studentInfoModel-" + stuId;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(stuId);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (Maticsoft.Model.studentInfo)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Maticsoft.Model.studentInfo> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Maticsoft.Model.studentInfo> DataTableToList(DataTable dt)
		{
			List<Maticsoft.Model.studentInfo> modelList = new List<Maticsoft.Model.studentInfo>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Maticsoft.Model.studentInfo model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Maticsoft.Model.studentInfo();
					if(dt.Rows[n]["stuId"]!=null && dt.Rows[n]["stuId"].ToString()!="")
					{
						model.stuId=int.Parse(dt.Rows[n]["stuId"].ToString());
					}
					if(dt.Rows[n]["stuNum"]!=null && dt.Rows[n]["stuNum"].ToString()!="")
					{
					model.stuNum=dt.Rows[n]["stuNum"].ToString();
					}
					if(dt.Rows[n]["stuName"]!=null && dt.Rows[n]["stuName"].ToString()!="")
					{
					model.stuName=dt.Rows[n]["stuName"].ToString();
					}
					if(dt.Rows[n]["stuAddress"]!=null && dt.Rows[n]["stuAddress"].ToString()!="")
					{
					model.stuAddress=dt.Rows[n]["stuAddress"].ToString();
					}
                    if (dt.Rows[n]["stuexamroom"] != null && dt.Rows[n]["stuexamroom"].ToString() != "")
                    {
                        model.stuexamroom = dt.Rows[n]["stuexamroom"].ToString();
                    }
					if(dt.Rows[n]["remark"]!=null && dt.Rows[n]["remark"].ToString()!="")
					{
					model.remark=dt.Rows[n]["remark"].ToString();
					}
					if(dt.Rows[n]["state"]!=null && dt.Rows[n]["state"].ToString()!="")
					{
						model.state=int.Parse(dt.Rows[n]["state"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

